﻿using FictionsDownload.DAL;
using FictionsDownload.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace FictionsDownload.BLL
{
    /// <summary>
    /// BLL查询数据的基础，BLL无法直接访问dal
    /// </summary>
    public class EfBLL:IDAL
    {
        protected IDAL dal = null;
        public int SaveChanges()
        {
            return dal.SaveChanges();
        }

        public IQueryable<T> All<T>() where T : class
        {
            return dal.All<T>();
        }

        public IQueryable<T> Set<T>() where T : class
        {
            return dal.Set<T>();
        }

        public void Insert<T>(T entity) where T : class
        {
            dal.Insert(entity);
        }

        public void Update<T>(T entity) where T : class
        {
            dal.Update(entity);
        }

        public void Delete<T>(T entity) where T : class
        {
            dal.Delete(entity);
        }

        public void Delete<T>(Expression<Func<T, bool>> conditions) where T : class
        {
            dal.Delete(conditions);
        }

        public T Find<T>(object Id) where T : class
        {
            return dal.Find<T>(Id);
        }

        public List<T> SqlQuery<T>(string sql)
        {
            return dal.SqlQuery<T>(sql);
        }

        public int ExecuteSqlCommand(string sql)
        {
            return dal.ExecuteSqlCommand(sql);
        }

        public long GetNextSequenceValue(string sequenceName)
        {
            return dal.GetNextSequenceValue(sequenceName);
        }

        public void Dispose()
        {
            dal.Dispose();
        }
    }
}
